package com.spring.springboot.dao;

import com.spring.springboot.entity.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;
@Repository
public class TestDao {
    private JdbcTemplate jdbcTemplate;

    @Autowired
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate){
         this.jdbcTemplate=jdbcTemplate;
    }

    public List<Test> getTestList(){
        List<Test> list = jdbcTemplate.query("select * from test",new Object[]{},new BeanPropertyRowMapper(Test.class));
        if(list!=null && list.size()>0){
            return list;
        }else{
            return null;
        }
    }

}
